package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import beans.Follow;
import beans.Member;
import service.FollowService;
import service.TypeService;
import serviceimpl.FollowServiceIpmt;
import serviceimpl.TypeServiceIpmt;

@WebServlet("/FollowServlet")
public class FollowServlet extends HttpServlet {
	private FollowService fs = new FollowServiceIpmt();
	private Follow follow = new Follow();
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		Member followmember = (Member) session.getAttribute("othermember");
		Member member = (Member) session.getAttribute("member");
		follow.setUsername(member.getUsername());
		follow.setFollowusername(followmember.getUsername());
		fs.addFollow(follow);

		session.setAttribute("followStatus", follow.getStatus());
		response.sendRedirect("/zzLoveProduct/home/otherhome.jsp");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}